<?php 
include 'ini.php';
include 'header.php';
if (isLoggedIn())
{
    header('Location: index.php');
    exit;
}
?>
<script type="text/javascript">

function checkForm()
{
    var email = document.getElementById('email').value;
    var password = document.getElementById('password').value;
    
    if (email.length < 1)
    {
        document.getElementById("emailDiv").className = 'form-group has-error';
    }
    else
    {
        document.getElementById("emailDiv").className = 'form-group has-success';
    }
    
    if (password.length < 1)
    {
        document.getElementById("passwordDiv").className = 'form-group has-error';
    }
    else
    {
        document.getElementById("passwordDiv").className = 'form-group has-success';
    }
    
    return email.length > 0 && password.length > 0;
}

function runScript(e) {
    if (e.keyCode == 13) {
        
        return checkForm();
    }
}

</script>


<div class="loneTitle">Welcome back!</div>

 <?php if (isset($_GET['err']) ) 
     {
        echo '<p class="loginError alert-danger">';
        echo "Incorrect login combination.";
        echo "</p>";
     };
     ?>

<div style="margin: auto; width: 300px;">
    <form id="signin-form" method="post" action="p_signin.php"  onkeypress="return runScript(event)">    
  <fieldset>
      <center>
      <legend></legend>
      </center>
      <div class="form-group" id="emailDiv">
      <label for="exampleInputEmail">Email/Username</label>
      <input type="text" class="form-control" id="email" name="email" placeholder="Enter email or username">
    </div>
            
    <div class="form-group" id="passwordDiv">
      <label for="exampleInputPassword">Password</label>
      <input type="password" class="form-control" id="password" name="password" placeholder="Password">
    </div>
  </fieldset>
       <button type="submit" class="btn btn-primary btn-block" onclick="return checkForm();">Sign in to your account</button>
</form>
</div>